<?php
/**
 * Created by PhpStorm.
 * User: MrHung
 * Date: 8/13/14
 * Time: 1:53 PM
 */
require_once('../../class_ajax_request/classAjaxAdmin.php');
include_once('../../application/functions.php');
include_once('../../application/DataConfig.php');

$obj = new AjaxRequestAdmin();



$file = $_FILES;
$file_name = $file['file']['name'];
$file_tmp = $file['file']['tmp_name'];
$file_size = $file['file']['size'];
$file_error = $file['file']['error'];
$file_type = $file['file']['type'];
    $time = time();
    $fileName = $file_name;
    $fileTmpLoc = $file_tmp;
// Path and file name
    $pathAndName = "../../upload/".$time.$fileName;
// Run the move_uploaded_file() function here

//check same image

//end check same image
    $moveResult = move_uploaded_file($fileTmpLoc, $pathAndName);
    $check = $obj->checkSameImage($time.$file_name);
    if($check == true){
        unlink($pathAndName);
        echo 0;
    }else{
        echo $time.$fileName;
        die;
    }
